<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
    <style>
        #overlay {
            background: rgba(0, 0, 0, 0.6);
            width: 100%;
            margin: auto;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
        }
        
        #center {
            background: #ffff;
            border-radius: 5px;
            padding-top: 15px;
            padding-left: 30px;
            padding-bottom: 15px;
            width: 290px;
            height: 160px;
            position: fixed;
            margin: auto;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
        }
    </style>
</head>

<body>

    <div id="app">
        <button @click="isShow=!isShow">模态框</button>

        <!-- 方法一 -->
        <!-- <div id="overlay" v-show="isShow" @click="isShow=false">
            <div id="center" @click.stop>
                用户名：
                <input/>
                <button @click="isShow=false">登录</button>
            </div>
        </div> -->
        <!-- 方法二 -->
        <div id="overlay" v-show="isShow" @click.self="isShow=false">
            <div id="center">
                用户名：
                <input/>
                <button @click="isShow=false">登录</button>
            </div>
        </div>
    </div>
    <script>
        var obj = {
            data() {
                return {
                    isShow: false
                }
            },
        }

        Vue.createApp(obj).mount('#app')
    </script>



</body>

</html>